import {computed} from "vue";
import {TPodoListProps} from "../../../todo";


export default function useCRUD(todoListProps:TPodoListProps){
//计算总数
    const totalNum = computed(()=>todoListProps.todoList.length)
//计算已选
    const checkedNum = computed(()=>todoListProps.todoList.reduce((pre,cur)=>cur.checked? pre+1:pre,0))
//是否选中
    const isChecked = computed(()=>todoListProps.todoList.length!==0 && todoListProps.todoList.every(item=>item.checked))

    return {totalNum,checkedNum,isChecked}
}